﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MSMQTriggerObjects;

namespace MSMQ.Triggers
{
	/// <summary>
	/// Manages an MSMQ trigger.
	/// </summary>
	public class Trigger
	{
		private string _id;
		private string _name;
		private string _queueName;
		private SystemQueueIdentifier _sysQueueId;
		private int _ruleCount;
		private bool _isEnabled;
		private bool _isSerialized;
		private MsgProcessingType _msgProcessingType;

		/// <summary>
		/// Gets or sets the Id of the trigger.
		/// </summary>
		public string Id
		{
			get { return _id; }
			internal set { _id = value; }
		}

		/// <summary>
		/// Gets or sets the name of the trigger.
		/// </summary>
		public string Name 
		{
			get { return _name; }
			internal set { _name = value; }
		}

		/// <summary>
		/// Gets or sets the queue path that the trigger is associated with.
		/// </summary>
		public string QueueName 
		{
			get { return _queueName; }
			internal set { _queueName = value; } 
		}

		/// <summary>
		/// Gets or sets the system queue identifier (journal, dead-letter-queue, etc.).
		/// </summary>
		public SystemQueueIdentifier SystemQueueIdentifier 
		{
			get { return _sysQueueId; }
			set { _sysQueueId = value; }
		}

		/// <summary>
		/// Gets or sets the number of rules attached to the trigger.
		/// </summary>
		public int RuleCount 
		{
			get { return _ruleCount; }
			internal set { _ruleCount = value; } 
		}

		/// <summary>
		/// Gets or sets whether the trigger is enabled or disabled.
		/// </summary>
		public bool IsEnabled 
		{
			get { return _isEnabled; }
			set { _isEnabled = true; }
		}

		/// <summary>
		/// Gets or sets whether the trigger is serialized.
		/// </summary>
		public bool IsSerialized
		{
			get { return _isSerialized; }
			set { _isSerialized = value; }
		}

		/// <summary>
		/// Gets or sets how the trigger processes messages (i.e. does it pull off the message 
		/// as the message arrives or allow it to stay in the queue).
		/// </summary>
		public MsgProcessingType MessageProcessingType
		{
			get { return _msgProcessingType; }
			set { _msgProcessingType = value; }
		}
	}
}